//
//  WeexSDKManager.m
//  WeexDemo
// https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1555490264891&di=10f82d924003b2446ab5e1858ad76a49&imgtype=0&src=http%3A%2F%2Fphotocdn.sohu.com%2F20131022%2FImg388642374.jpg https://b-ssl.duitang.com/uploads/item/201504/03/20150403H1232_RJ2iV.thumb.700_0.jpeg
//  Created by yangshengtao on 16/11/14.
//  Copyright © 2016年 taobao. All rights reserved.
//

#import "WeexSDKManager.h"
#import <WeexSDK/WeexSDK.h>
#import "WXImgLoaderDefaultImpl.h"
#import "WXNavPushImpl.h"

@implementation WeexSDKManager
singleton_implementation(WeexSDKManager)

+ (void)setup;
{
    NSURL *url = nil;
#if DEBUG
    //If you are debugging in device , please change the host to current IP of your computer.
    url = [NSURL URLWithString:BUNDLE_URL];
#else
    url = [NSURL URLWithString:BUNDLE_URL];
#endif
    NSString * entryURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"WXEntryBundleURL"];
    if (entryURL) {
        if ([entryURL hasPrefix:@"http"]) {
            url = [NSURL URLWithString:entryURL];
        } else {
            url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[[NSBundle bundleForClass:self] resourceURL].absoluteString, entryURL]];
        }
    }
    
#ifdef UITEST
    url = [NSURL URLWithString:UITEST_HOME_URL];
#endif
    
    [self initWeexSDK];
    //[self loadCustomContainWithScannerWithUrl:url];
}

+ (void)initWeexSDK
{
    [WXAppConfiguration setAppGroup:@"AliApp"];
    [WXAppConfiguration setAppName:@"WeexDemo"];
    [WXAppConfiguration setAppVersion:@"1.8.3"];
    [WXAppConfiguration setExternalUserAgent:@"ExternalUA"];
    
    [WXSDKEngine initSDKEnvironment];
    
    [WXSDKEngine registerHandler:[WXImgLoaderDefaultImpl new] withProtocol:@protocol(WXImgLoaderProtocol)];
    [WXSDKEngine registerModule:@"WXNavModule" withClass:NSClassFromString(@"WXNavPushImpl")];
#ifdef DEBUG
    [WXLog setLogLevel:WXLogLevelAll];
#endif
}

@end
